package com.cskaoyan.controller.wx;

import com.cskaoyan.bean.BasePageInfo;
import com.cskaoyan.bean.vo.BaseRespVo;
import com.cskaoyan.bean.vo.search.SearchIndexVO;
import com.cskaoyan.service.admin.MarketSearchHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author LC_RSH
 * @date 2022/6/28 21:18
 */
@RestController
@RequestMapping("wx/search")
@Transactional
public class WXSearchController {
    @Autowired
    MarketSearchHistoryService searchHistoryService;

    /**
     * 搜索页面关键词显示
     *
     * @return
     * @author LC_R-SH
     * @since 2022/06/28 22:31
     */
    @RequestMapping("index")
    public BaseRespVo index() {
        SearchIndexVO historyCommonData = searchHistoryService.index();
        return BaseRespVo.ok(historyCommonData);
    }

    /**
     * 模糊查找关键词列表 返回含有关检测的list
     *
     * @return
     * @author LC_R-SH
     * @since 2022/06/28 22:35
     */
    @RequestMapping("helper")
    public BaseRespVo helper(String keyword) {
        BaseRespVo baseRespVo = searchHistoryService.helper(keyword);
        return baseRespVo;
    }

    /**
     * 删除历史记录 修改状态值即可
     *
     * @return
     * @author LC_R-SH
     * @since 2022/06/28 22:47
     */
    @RequestMapping("clearhistory")
    public BaseRespVo clearHistory() {
        BaseRespVo baseRespVo = searchHistoryService.clearHistory();
        return baseRespVo;
    }

    /**
     * 通过关检测查找商品,增加搜索历史及关键词列表,更新时间
     * @return
     * @author LC_R-SH
     * @since 2022/06/28 22:57
     */
    @RequestMapping("list")
    public BaseRespVo list(String keyword, BasePageInfo info) {
        BaseRespVo baseRespVo = searchHistoryService.list(keyword, info);
        return baseRespVo;
    }


}

/**
 * 搜索
 *
 * @author 86157
 * @since 2022/06/28 21:18
 */